/*
 * Copyright (C) 2010 Fred Barrie This program is free software: you can
 * redistribute it and/or modify it under the terms of the GNU General Public
 * License as published by the Free Software Foundation, either version 3 of the
 * License, or (at your option) any later version. This program is distributed
 * in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
 * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 * See the GNU General Public License for more details. You should have received
 * a copy of the GNU General Public License along with this program. If not, see
 * <http://www.gnu.org/licenses/>.
 */
package org.aergia.vinny.database.pojo;

import javax.xml.xpath.XPath;
import javax.xml.xpath.XPathConstants;
import javax.xml.xpath.XPathFactory;

import junit.framework.Assert;
import junit.framework.TestCase;

import org.w3c.dom.Document;

/**
 * @author fred
 */
public class PojoTestCase extends TestCase {

	protected Class<? extends DatabasePojo> pojo;

	public PojoTestCase() {
		this.pojo = Card.class;
	}

	protected PojoTestCase(final Class<? extends DatabasePojo> pojo) {
		this.pojo = pojo;
	}

	public void testGetId() throws Exception {
		final DatabasePojo instance = this.pojo.newInstance();
		Assert.assertEquals(0, instance.getId());
	}

	public void testIsActive() throws Exception {
		final DatabasePojo instance = this.pojo.newInstance();
		Assert.assertEquals(false, instance.isActive());
	}

	protected void assertXpath(final String expression, final Document document) throws Exception {
		final XPathFactory factory = XPathFactory.newInstance();
		final XPath xpath = factory.newXPath();
		Assert.assertEquals(Boolean.TRUE, xpath.evaluate(expression, document, XPathConstants.BOOLEAN));
	}
}
